package com.ruoyi.web.controller.shop;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.domain.DayIncome;
import com.ruoyi.shop.service.IDayIncomeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 利润日清Controller
 * 
 * @author ruoyi
 * @date 2024-06-14
 */
@RestController
@RequestMapping("/shop/dayIncome")
public class DayIncomeController extends BaseController
{
    @Autowired
    private IDayIncomeService dayIncomeService;

    /**
     * 查询利润日清列表
     */
    @PreAuthorize("@ss.hasPermi('shop:dayIncome:list')")
    @GetMapping("/list")
    public TableDataInfo list(DayIncome dayIncome)
    {
        startPage();
        List<DayIncome> list = dayIncomeService.selectDayIncomeList(dayIncome);
        return getDataTable(list);
    }

    /**
     * 导出利润日清列表
     */
    @PreAuthorize("@ss.hasPermi('shop:dayIncome:export')")
    @Log(title = "利润日清", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DayIncome dayIncome)
    {
        List<DayIncome> list = dayIncomeService.selectDayIncomeList(dayIncome);
        ExcelUtil<DayIncome> util = new ExcelUtil<DayIncome>(DayIncome.class);
        util.exportExcel(response, list, "利润日清数据");
    }

    /**
     * 获取利润日清详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:dayIncome:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dayIncomeService.selectDayIncomeById(id));
    }

    /**
     * 新增利润日清
     */
    @PreAuthorize("@ss.hasPermi('shop:dayIncome:add')")
    @Log(title = "利润日清", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DayIncome dayIncome)
    {
        return toAjax(dayIncomeService.insertDayIncome(dayIncome));
    }

    /**
     * 修改利润日清
     */
    @PreAuthorize("@ss.hasPermi('shop:dayIncome:edit')")
    @Log(title = "利润日清", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DayIncome dayIncome)
    {
        return toAjax(dayIncomeService.updateDayIncome(dayIncome));
    }

    /**
     * 删除利润日清
     */
    @PreAuthorize("@ss.hasPermi('shop:dayIncome:remove')")
    @Log(title = "利润日清", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dayIncomeService.deleteDayIncomeByIds(ids));
    }
}
